package cqrtplm.entity;

import java.util.Date;
import java.util.List;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.hutool.core.collection.IterUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hustcad.plm.basic.entity.BaseEntity;
import cqrtplm.dto.DspfDemandDevpDTO;
import cqrtplm.dto.RtCfgDemandOrdersDTO;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
 * 需求排程对象 DSPF_Demand_DevPlan
 *
 * @author 江小雄
 * @date 2025-06-23
 */
@Data
public class DspfDemandDevplanDO
{

    private static final long serialVersionUID = 1L;

    /** 计划ID */
    private String DevPlanID;

    /**需求状态表id*/
    private String statusid;

    /**流程编码*/
    private String flowCode;

    /** 计划类型，0动力、1机组 */
    @Excel(name = "计划类型，0动力、1机组（终端）、2传动")
    private Integer DevPlanType;

    /** 状态 */
    @Excel(name = "状态")
    private Integer Status;

    /** StateFolwNo */
    private String StateFolwNo;

    /** ReferMBomID */
    private String ReferMBomID;

    /** ReferMBomCode */
    private String ReferMBomCode;

    /** ReferEBomID */
    private String ReferEBomID;

    /** ReferEBomCode */
    private String ReferEBomCode;

    /** 分配人 */
    @Excel(name = "分配人")
    private String CreateUserID;

    /** 创建时间 */
    private Date CreateTime;

    /** 是否作废 */
    private Integer IsDelete;

    /** 作废类型 */
    private Long DeleteType;

    /** 机组动力是否包装 1是 0否*/
    private String IsDLPack;

    private String Remark;

    /** DeleteUserID */
    private String DeleteUserID;

    /** 小批备注 */
    private String SmallBatchRemark;

    /** 外购动力 */
    private String PurchasedPower;

    /** 动力完善 */
    private String PerfectPower;

    /** 计划完成时间 */
    private Date CompletionTime;

    /** 退回说明 */
    private String ReturnExplain;

    /** 是否是配置搭建  1是  0否（直接成品码生成） */
    private String Configuration;

    /** 需求类型 */
    @Excel(name = "需求类型")
    private String DemandType;

    /** 需求MainID */
    private String DemandMainID;

    /** VIN码 */
    private String VinCode;

    /** 指定列表 */
    private String ListNo;

    /** 需求编码 */
    @Excel(name = "需求编码")
    private String DemandCode;

    /** 0是成品码变化  1需求表 */
    private Integer IsHistoryOrder;

    /** 冻结   null正常  0变更中 1冻结   2失效   4结束 */
    private Integer Frozen;

    /** 状态编码ID */
    private String ObjectID;

    /** 开发等级 */
    @Excel(name = "开发等级")
    private String DevGrade;

    /** 特殊处理意见 */
    private String SpecialOpinions;

    /** 是否允许动力搭建 */
    private String AllowPowerBuild;

    /** 是否需要包装搭建  1需要  0不需要 */
    private String PackingBuild;

    /** 是否需要贴花搭建  1需要  0不需要 */
    private String AppliqueBuild;

    /** 变更编码 */
    private String ModifyNO;

    /** 终端工厂 */
    private String TerminalFactory;

    /** 动力工厂 */
    private String PowerFactory;

    /** 状态室接收时间 */
    private Date DevplanReceiveTime;

    /** 状态室分配时间 */
    private Date DevplanStartTime;

    /** 初次计划结束时间 */
    private Date DevplanScheduleTime;

    /** 实际计划结束时间 */
    private Date DevplanRealScheduleTime;

    /** 当前流程状态 */
    @Excel(name = "当前流程状态")
    private String DevplanProcess;

    /** 当前节点名称 */
    @Excel(name = "当前节点名称")
    private String DevplanCurrentStepName;

    /** 当前节点用户 */
    private String DevplanCurrentStepUserID;

    /** 当前节点用户 */
    private String DevplanCurrentStepUserName;

    /** 当前节点ID */
    private String DevplanCurrentTaskID;

    /** 当前节点开始时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "当前节点开始时间", width = 30)
    private Date DevplanCurrentStepStartTime;

    private String SignToOtherDPT;

    /**动力管理员*/
    private String powerAdministrator;
    /**动力说明*/
    private String powerDescription;
    /**机组管理员*/
    private String crewAdministrator;
    /**机组说明*/
    private String crewDescription;
    /**传动管理员*/
    private String tranAdministrator;
    /**传动说明*/
    private String tranDescription;

    /** 创建时间 */
    private Date createDate;
    /** 创建人 */
    private String createUser;
    /** 更新时间 */
    private Date updateDate;
    /** 更新人 */
    private String updateUser;


    //产品类别
    @TableField(exist = false)
    private String category;
    //客户
    @TableField(exist = false)
    private String customer;
    //销售国
    @TableField(exist = false)
    private String salesCountry;
    //机型
    @TableField(exist = false)
    private String model;
    //数量
    @TableField(exist = false)
    private Long quantity;

    //客户交期时间
    @TableField(exist = false)
    private Date customerDeliveryTime;

    //接单时间
    @TableField(exist = false)
    private Date orderReceivedTime;

    //开始处理时间
    @TableField(exist = false)
    private Date startProcessingTime;

    //预估完成时间
    @TableField(exist = false)
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date estimatedCompletionTime;

    //任务状态
    @TableField(exist = false)
    private String taskStatus;

    //当前节点接收时间
    @TableField(exist = false)
    private Date currentNodeReceivedTime;

    //变更延期原因
    private String changeDelayReason;

    /** 配置 */
    @Excel(name = "配置")
    private String configuration;

    /** 组动单包 */
    @Excel(name = "组动单包")
    private String assemblyPackage;

    /** 无需动力 */
    @Excel(name = "无需动力")
    private String noPowerRequired;

    /** 包装组 */
    @Excel(name = "包装组")
    private String packagingGroup;

    /** 贴花组 */
    @Excel(name = "贴花组")
    private String stickerGroup;

    /** 检小批 */
    @Excel(name = "检小批")
    private String inspectionSmallBatch;

    /** 流程分配节点:是否分配 0未分配 1已分配 */
    private Integer isAllocate;

    //无需处理的流程节点
    private String flownodeauthstr;

    public DspfDemandDevplanDO () {

    }

    public DspfDemandDevplanDO (RtCfgDemandOrdersDTO dto,DspfDemandDevpDTO dsp) {
        this.DevPlanID = dto.getId();
        this.statusid = dto.getStatusid();//新增字段
        this.flowCode = dto.getFlowCode();
        this.CreateUserID = dto.getCreator();
        this.CreateTime = new Date();
        this.IsDLPack = dto.getAssemblyPackage();
        this.CompletionTime = dto.getActualCompletionTime();
        this.Configuration = dto.getConfiguration();
        this.AllowPowerBuild = dto.getNoPowerRequired();
        this.PackingBuild = dto.getPackagingGroup();
        this.AppliqueBuild = dto.getStickerGroup();
        this.TerminalFactory = dto.getTerminalFactory();
        this.PowerFactory = dto.getPowerFactory();
        this.DemandCode = dto.getDemandCode();
        this.DemandType = dto.getDemandType();
        this.DevGrade = dto.getDemLevel();
        this.estimatedCompletionTime = dto.getEstimatedCompletionTime();
        this.powerAdministrator = dsp.getPowerAdmin();
        this.powerDescription = dsp.getPowerDescription();
        this.crewAdministrator = dsp.getUnitAdmin();
        this.crewDescription = dsp.getUnitDescription();
        this.tranAdministrator = dsp.getTranAdministrator();
        this.tranDescription = dsp.getTranDescription();
        this.isAllocate = 1;
        this.category = dto.getCategory();
        this.DemandType = dto.getDemandType();
        this.customer = dto.getCustomer();
        this.salesCountry = dto.getSalesCountry();
        this.model = dto.getModel();
        this.quantity = dto.getQuantity();

    }

    public DspfDemandDevplanDO (DspfDemandDevpDTO dto) {
        this.DevPlanID = dto.getDevPlanID();
        this.DemandCode = dto.getDemandCode();
        this.changeDelayReason = dto.getChangeDelayReason();//新增字段
        this.estimatedCompletionTime = dto.getEstimatedCompletionTime();
    }

}
